/*年轻人，只管向前看，不要管自暴自弃者的话*/
package com.znb.okdown.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.znb.okdown.databinding.FragmentHomeBinding
import com.znb.okdown.flutter.FlutterCacheManager
import io.flutter.embedding.android.FlutterActivity


/**
 * create by itz on 2024/1/17 9:18
 * desc :
 **/
class HomeFragment : BaseFragment() {

    lateinit var binding: FragmentHomeBinding

    companion object {
        fun newInstance(): HomeFragment {
            return HomeFragment()
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentHomeBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.apply {
            toFlutterHomePage.setOnClickListener {
                context?.let {
                    val intent =
                        FlutterActivity.withCachedEngine(FlutterCacheManager.HOME).build(it)
                    startActivity(intent)
                }
            }

            toFlutterMinePage.setOnClickListener {
                context?.let {
                    val intent =
                        FlutterActivity.withCachedEngine(FlutterCacheManager.MINE).build(it)
                    startActivity(intent)
                }
            }
        }
    }
}